package com.yycx.module.bus.provider.handler.process.listener;

import com.yycx.common.base.utils.FlymeUtils;
import com.yycx.common.constants.CommonConstants;
import com.yycx.module.bus.client.entity.BusOrder;
import com.yycx.module.bus.provider.service.BusOrderDetailsService;
import com.yycx.module.bus.provider.service.BusOrderService;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 资信认款审批监听器
 *
 * @author zyf
 */
@Component
public class OrderRenkuanTaskListener implements TaskListener {
    @Resource
    private BusOrderService orderService;

    @Resource
    private BusOrderDetailsService orderDetailsService;

    @Override
    public void notify(DelegateTask delegateTask) {
        String businessKey = delegateTask.getVariable("businessKey", String.class);
        BusOrder order = orderService.getById(businessKey);
        Integer customBondType = order.getCustomBondType();
        if (!customBondType.equals(5) && !customBondType.equals(0)) {
            //更新为已认款
            orderDetailsService.updateCustomBondState(order.getOrderId(), CommonConstants.INT_1);
        }
    }
}
